var commonObject = function(){
	this.GLOBAL_HOST = 'http://dev-esheyi.yingjiashenghuo.com';
	// this.GLOBAL_HOST = 'http://wxapi35.esheyi.com';
	// this.GLOBAL_HOST = 'http://api.esheyi.com';
	this.AUDIO_LIST = '/agent-service/api/audioInfo/getAudioList.do';
	this.LOGO_URL = 'http://audio.esheyi.com/img/sheyi_logo.png';
	this.regWarp=/##br##/g;
};
commonObject.prototype = {
	getQueryString:function(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]);
        return null;
    },
    isWeiXinNavigator:function(){
        var ua = window.navigator.userAgent.toLowerCase();
        if(ua.match(/MicroMessenger/i) == 'micromessenger'){
            return true;
        }else{
            return false;
        }
    },
    photoScale:function(selector){
		var selector=$(selector);
        new RTP.PinchZoom(selector, {});
		var screenHeight = window.screen.height;
		selector.height(screenHeight);
		selector.parent().height(screenHeight);
		selector.children('img').css({'position':'absolute','top':'40%','left':'50%','transform':'translate(-50%,-50%)','-webkit-transform':'translate(-50%,-50%)'});
	},
    requestFormData:function (options) {
        var self=this;
        var url=options.url;
        var sendData=options.sendData;
        var resSuccess=options.resSuccess;
        var resFailed=options.resFailed;
        var resError=options.resError;
        jQuery.support.cors = true;
        $.ajax
        ({
            data:sendData,
            type: "POST",
            contentType: "application/x-www-form-urlencoded;charset=utf-8",
            dataType:"json",
            url:url,
            success:function(data){
                if(typeof data==="string"){
                    data=JSON.parse(data);
                }
                if(!!data && data['code']=="0"){
                    sendData={};
                     !!resSuccess&&$.isFunction(resSuccess)&&resSuccess(data);
                }else{
                    !!resFailed&&$.isFunction(resFailed)&&resFailed(data);
                }
            },
            timeout:10000,
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                !!resError&&$.isFunction(resError)&&resError();
            }
        });
    }
}
window.common = new commonObject();
